<?php
/**
 * 收货地址管理模型
 * @author e5
 *
 */
class AddressModel extends Model{
	public $table = "address";
	public $validate = array(
			array("ieceovername","nonull","收货人不能为空",2,3),
			array("ProvinceID","nonull","请选择省份/直辖市",2,3),
			array("CityID","nonull","请选择市",2,3),
			array("AreaID","nonull","请选择县/区",2,3),
			array("detailarea","nonull","详细地址不能为空",2,3),
			array("postalcode","nonull","邮编不能为空",2,3),
			array("arphone","phone","手机号格式错误",2,3)
	);
	public $auto = array(
			array("arisdefault","intval","funciton",1,3),
			array("ararea","_getArea","method",2,3),
			array("vshop_user_uid","_getUid","method",2,1)
	);
	//组合地区
	public function _getArea(){
		return Q("post.ProvinceID")."省".Q("post.CityID")."市".Q("post.AreaID");
	}
	public function _getUid(){
		return session("uid");
	}
	//添加收货地址
	public function addArea(){
		if (!$this->create()) return false;
		return $this->add();
	}
}